#include "formtclass.h"
#include "ui_formtclass.h"
#include<QSqlQueryModel>
#include<QDebug>
#include"teacher.h"
#include"execsql.h"

Formtclass::Formtclass(QWidget *parent) :
    QWidget(parent),
    ui(new Ui::Formtclass)
{
    ui->setupUi(this);
}

Formtclass::~Formtclass()
{
    delete ui;
}

void Formtclass::Windowshow(QString classid,QString checkintime,QString id)
{
    emit signalformtclass();
    this->show();

    ExecSQL ex;
    str = id;
    m_str = ex.selectTeacherInfo(id).getteacherID();
    QSqlQueryModel *modelt = new QSqlQueryModel(ui->tableView_checkinclass);
    ui->lineEdit_checkin_classid->setPlaceholderText(tr("%1").arg(classid));
    QString sqlquery = QString("select * from CheckinInfoTable where"
                               " Classid = "+classid+" and CheckinTime = "+checkintime+"and teacherId = "+ id+";");
    qDebug()<<"sqlquery=="<<sqlquery;

     modelt->setQuery(sqlquery);
    //列名
    modelt->setHeaderData(0, Qt::Horizontal, tr("XID"));
    modelt->setHeaderData(1, Qt::Horizontal, tr("ScienceID"));
    modelt->setHeaderData(2, Qt::Horizontal, tr("teacherId"));
    modelt->setHeaderData(3, Qt::Horizontal, tr("Classid"));
    modelt->setHeaderData(4, Qt::Horizontal, tr("RoomID"));
    modelt->setHeaderData(5, Qt::Horizontal, tr("CheckinTime"));
    modelt->setHeaderData(6, Qt::Horizontal, tr("xuehao"));

    ui->tableView_checkinclass->setModel(modelt);//数据放置进去
    ui->tableView_checkinclass->verticalHeader()->hide();//不显示序号
}

void Formtclass::showtw()
{
    Teacher *tw = new Teacher;
    tw->show();
    tw->selectBoxSlot( str);
}

void Formtclass::on_pb_checkin_cancle_clicked()
{
    this->close();
    this->showtw();
}
